﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Indeco.G24.Web;
using Indeco.G24.Entities;
using Indeco.G24.Services;


namespace Indeco.G24.Website
{
    public partial class Login : G24Page
    {
        //NguoiDung nguoiDung = new NguoiDung();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Đăng nhập";
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void frmLogIn_LoggedIn(object sender, EventArgs e)
        {
            if (Request.QueryString["ReturnUrl"] != "")
            {
                Response.Redirect(Server.UrlDecode(Request.QueryString["ReturnUrl"]));
            }
            //TList<NguoiDung> nguoiDung = nguoiDungService.Find("TenSuDung = '" + Membership.GetUser().UserName + "'");
            //Session["IDNguoiDung"] = nguoiDung[0].IDNguoiDung;
            //Label1.Text = Session["IDNguoiDung"].ToString();

        }

        protected void LoginButton_Click(object sender, EventArgs e)
        {
            try
            {
                NguoiDungService nguoiDungService = new NguoiDungService();
                TList<NguoiDung> nguoiDung = nguoiDungService.Find("TenSuDung = '" + Membership.GetUser().UserName + "'");
                Session["IDNguoiDung"] = nguoiDung[0].IDNguoiDung;
                Label1.Text = Session["IDNguoiDung"].ToString();
                NguoiDungNhaCungCapService nguoiDungNhaCungCapService = new NguoiDungNhaCungCapService();
                TList<NguoiDungNhaCungCap> listNN = nguoiDungNhaCungCapService.GetByIDNguoiDung(new Guid(Session["IDNguoiDung"].ToString()));
                Session["IDNhaCungCap"] = listNN[0].IDNhaCungCap;
            }
            catch
            { }
        }
    }
}
